package com.feicheng.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.feicheng.common.result.ResultInfo;
import com.feicheng.persistence.entity.About;
import com.feicheng.persistence.service.IAboutService;
import com.feicheng.service.IFAboutService;

@Service
public class FAboutServiceImpl implements IFAboutService {
	
	@Autowired
	IAboutService aboutService;

	@Override
	public ResultInfo getAbout(Integer aboutId) {
		
		
		//如果获取的about表主键about_id为空
		
		
		if (null == aboutId) {
			
			//则取about表中的所有值
			QueryWrapper<About> queryWrapperAbout = new QueryWrapper<>();
			
			
			queryWrapperAbout.gt("about_id", 0);
			
			//返回about表中的第一个值
			return ResultInfo.success(aboutService.list(queryWrapperAbout).remove(0));
			
		}

		//以about_id为条件取得about表的详细信息
		
		
		QueryWrapper<About> queryWrapperAbout = new QueryWrapper<>();
		queryWrapperAbout.eq("about_id", aboutId);

		About about = aboutService.getOne(queryWrapperAbout);
		
		return ResultInfo.success(about);
		
	}

	@Transactional
	@Override
	public ResultInfo updataAbout(About about){
		// 根据about_id更改contant
		
		aboutService.updateById(about);
		
			
		return ResultInfo.success();
	}
	
	
}
